<?php
/**
 * Created by PhpStorm.
 * User: leesin
 * Date: 2018/4/26
 * Time: 16:26
 */
namespace app\index\controller;
use app\index\model\OpenIdModel;
use think\Controller;

class Getopenid extends Controller{

    public $model;
    public $openId;

    //构造函数(初始化Url类)
    public function __construct(){
        parent::__construct();
        $this->model = new OpenIdModel();
    }

    //获取openid
    public function getOpenId(){
        $this->redirect($this->model->getOpenId());
        return $this->openId;
    }

    //跳转获取openid的链接（此方法的url需要填写到model的redirect_uri）
    public function index() {
        //dump(input('get.'));die;
        $this->openId = $this->model->refreshAccessToken($this->model->getAccessToken());
    }


}